import React, { Component } from 'react';
import classnames from 'classnames';
import { Card, Icon, Tooltip, Button, Col, Row } from 'antd';
import QueueAnim from 'rc-queue-anim';
import styles from './List.less';

class List extends Component {
  render() {
    const {
      data,
      loading,
      handleDelete,
    } = this.props;
    // jixiexinxi_nongjizulin
    const listItem = (v, i) => (
      <Col key={v.id} md={6} xs={12}>
        <Card
          title={<span>{i + 1} {v.isMyPost && <Tooltip title="我发布"><Icon type="user" /></Tooltip>}</span>}
          className={styles.cardWrapper}
          extra={v.isMyPost && (
            <div className={styles.operationWrapper}>
              <Tooltip title={<Button type="danger" onClick={() => handleDelete(v)}>确定</Button>}>
                <Icon type="delete" theme="filled" className={styles.icon} style={{ marginLeft: 12 }} />
              </Tooltip>
            </div>
          )}>
          <div className={classnames([styles.wrapper, styles.descWrapper])}>
            <Icon type="tag" theme="filled" style={{ color: 'green' }} />
            <span>{v.machineDesc}</span>
          </div>
          <div className={classnames([styles.wrapper, styles.priceWrapper])}>
            <Icon type="pay-circle" theme="filled" style={{ color: 'red' }} />
            <span>{v.price}</span>
          </div>
          <div className={classnames([styles.wrapper, styles.contactWrapper])}>
            <Icon type="phone" theme="filled" style={{ color: 'black' }} />
            <span>{v.contact}</span>
          </div>
          <div className={classnames([styles.wrapper, styles.timeWrapper])}>
            <Icon type="clock-circle" theme="filled" style={{ color: 'black' }} />
            <span>{v.time}</span>
          </div>
        </Card>
      </Col>
    );

    return (
      <Card loading={loading} className={styles.container}>
        <Row>
          <QueueAnim>
            {data.map(listItem)}
          </QueueAnim>
        </Row>
      </Card>
    );
  }
}

export default List;
